package com.hackerrank.challenges.hackerranklanguage;

import java.util.Scanner;

public class Solution {
	private static String l = "C:CPP:JAVA:PYTHON:PERL:PHP:RUBY:CSHARP:HASKELL:CLOJURE:BASH:SCALA:ERLANG:CLISP:LUA:BRAINFUCK:JAVASCRIPT:GO:D:OCAML:R:PASCAL:SBCL:DART:GROOVY:OBJECTIVEC";
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		in.nextLine();
		for(int n = 0; n < N; n++) {
			String s[] = in.nextLine().split(" ");
			if(l.startsWith(s[1] + ":") || l.contains(":" + s[1] + ":") || l.endsWith(":" + s[1]))
				System.out.println("VALID");
			else
				System.out.println("INVALID");
		}
	}
}
